(:
	add anchors to a display file that doesn't have any
 :)

import module namespace
    jj = "http://kumquat.emse.fr/utilitaires"
    at "jjutils.xq" ;
<display>{
let $aname := fn:tokenize($arguments[2],"/")[last()]
let $anitems := doc($arguments[2])/display/item
for $it in doc($arguments[1])/display/item
let $anchor := $it/info[@name="src-anchor"]/anchor
let $match := $anitems[info[@name="target-anchor"][1]/anchor = $it/info[@name="src-anchor"]/anchor][1]
return
<item>{
	(for $info in $it/info return $info,
	<info name="{$aname}">{$match/info[@name="comment"]/text()}</info>)
}</item>
}</display>